package com.easylinkin.linkappapi.safe.controller;

import com.easylinkin.linkappapi.safe.entity.HiddenConfig;
import com.easylinkin.linkappapi.safe.service.HiddenConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

/**
 * @author: kan yuanfeng
 * @Date: 2023/04/04 11:42
 * @Description: 安全管理通知设置管理
 */
@RestController
@RequestMapping("hiddenConfig")
@Api(tags = "安全管理通知设置管理")
public class HiddenConfigController {
  
  @Autowired
  private HiddenConfigService hiddenConfigService;

  /**
   * @Description: 增加通知设置
   * @author kan yuanfeng
   * @date 2023/04/04 11:42
   */
  @PostMapping
  @ApiOperation("增加通知设置")
  public RestMessage insert(@RequestBody HiddenConfig hiddenConfig){
    hiddenConfigService.insert(hiddenConfig);
    return RestBuilders.successBuilder().build();
  }

  /**
   * @Description: 编辑通知设置
   * @author kan yuanfeng
   * @date 2023/04/04 11:42
   */
  @PutMapping
  @ApiOperation("编辑通知设置")
  public RestMessage updateById(@RequestBody HiddenConfig hiddenConfig){
    Assert.notNull(hiddenConfig.getId(),"id不能为空");
    hiddenConfigService.updateOne(hiddenConfig);
    return RestBuilders.successBuilder().build();
  }

  /**
   * @Description: 查询通知设置详情
   * @author kan yuanfeng
   * @date 2023/04/04 11:42
   */
  @GetMapping
  @ApiOperation("查询通知设置详情")
  public RestMessage findOne() {
    HiddenConfig hiddenConfig = hiddenConfigService.findOne();
    return RestBuilders.successBuilder().data(hiddenConfig).build();
  }
}

